home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 7
/
FM Towns Free Software Collection 7.iso
/
t_os
/
gpen32k
/
source.exe
/
SRC
/
GPEN32KS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-04
|
3KB
|
155 lines
/*****************************************************************
G-Pen32k専用部
Copyright(C) 1991,1992,1993 Okome
*****************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <EGB.h>
#include <MOS.h>
#include <Normlib.h>
#include <GPen32k.h>
#include <GPenSub.c>
void tcl(int mb, int s)
{
int i, b, r, g;
s+=4;
if (s==4 || s==5)
{
mcl[s] = mcl[mb];
}
for (i = 0; i<CBX4; i++)
{
b = (( mcl[5] & 0x1f)*i+( mcl[4] & 0x1f)*(CBX4-i)+CBX4/2)/CBX4;
r = (((mcl[5]>> 5)& 0x1f)*i+((mcl[4]>> 5)& 0x1f)*(CBX4-i)+CBX4/2)/CBX4;
g = (((mcl[5]>>10)& 0x1f)*i+((mcl[4]>>10)& 0x1f)*(CBX4-i)+CBX4/2)/CBX4;
line( CBX1+i,CBY1,CBX1+i,CBY2, (g << 10) + (r << 5) + b );
}
boxf( CBLX1,CBLY1,CBLX2,CBLY2, mcl[4] );
boxf( CBRX1,CBRY1,CBRX2,CBRY2, mcl[5] );
}
void wsize( int s )
{
static int k=3;
int h = 2;
wget();
wpg(0);
boxf( (NX1-h)*bi-1, (NY1-h)*bi-1, (NX2+h+1)*bi, (NY2+h+1)*bi, BCL );
wkugiri(0);
nx[k] = NX1;
ny[k] = NY1;
k = (k+1) % (5+s);
if (k == 0)
wb = wallb;
else
if (k == 5)
wb = &(b[256*1024-32768]);
else
wb+=NX4 * NY4 * 2;
NX4 = (8/bi) << k;
NY4 = NX4;
NX1 = nx[k];
NY1 = ny[k];
wkugiri(1);
wpg(1);
wput();
wpg(0);
biboxbf( NX1, NY1, NX2, NY2, 0, 4, 4 );
wpg(1);
}
/* カラー選択パレット */
void mcolms( int j ) /* カラーバー □表示 */
{
int c;
c = ( mcl[0] / (1 << (j*5))) & 0x1f;
j = 2 - j;
boxf( PALX*bi + 1 , PALY*bi + j *PALB*bi + 1,
PALX*bi + 255, PALY*bi +(j+1)*PALB*bi - 1, 0 );
boxb( PALX*bi + c * 8 + 2, PALY*bi + j *PALB*bi + 2,
PALX*bi + c * 8 + 7, PALY*bi +(j+1)*PALB*bi - 1, 8 );
boxb( PALX*bi + c * 8 + 1, PALY*bi + j *PALB*bi + 1,
PALX*bi + c * 8 + 6, PALY*bi +(j+1)*PALB*bi - 2, 15 );
}
void mcols( int k )
{
int j;
if ( k != mcl[0] )
{
mcl[0] = k;
mbclp();
for ( k = 0; k <= 2; k++ )
{
EGB_writeMode( work, 3 );
boxf(PALX , PALY+(k+1)*PALB-2,
PALX+127, PALY+(k+1)*PALB-1, 0x1f * (1 << ((2 - k) * 5)));
EGB_writeMode( work, 2 );
boxf(PALX , PALY+(k+1)*PALB-2,
PALX+127, PALY+(k+1)*PALB-1,
mcl[0] & (0x7fff - 0x1f * (1 << ((2 - k) * 5))));
}
EGB_writeMode( work, 0 );
wpg(0);
for ( j=0; j<=2; j++)
mcolms(j);
wpg(1);
}
}
void ptnsave4pg( char *name, int sx, int sy )
{
int x, y, p;
FILE *fp;
if ((fp = fopen( name, "wb")) == NULL )
{ return; }
for (p=0; p<=3; p++ )
{
for ( y=0; y<128/sy; y++ )
{
for ( x=0; x<128/sx; x++ )
{
egbget(BX1+x*sx,BY1+y*sy,BX1+sx-1+x*sx,BY1+sy-1+y*sy,b);
fwrite(b, 1, sx*sy*2, fp);
}
}
page(1);
}
page(-4);
fclose(fp);
}
void ptnload4pg( char *name, int sx, int sy )
{
int x, y, p;
FILE *fp;
if ((fp = fopen( name, "rb")) == NULL )
{ return; }
for (p=0; p<=3; p++ )
{
for ( y=0; y<128/sy; y++ )
{
for ( x=0; x<128/sx; x++ )
{
fread(b, 1, sx*sy*2, fp);
egbput(BX1+x*sx,BY1+y*sy,BX1+sx-1+x*sx,BY1+sy-1+y*sy,b);
}
}
page(1);
}
page(-4);
fclose(fp);
}
void rchc( void )
{
int mb, mx, my;
mcl[0]^=0x8000;
mbclp();
mbout( &mb, &mx, &my );
}